public class Test3 {
    public static void main(String[] args) {
        //求1！+2！+3！+4！+........+n!的和
        int n=5;

        int sum=0;
        for(int j=1; j<=n; ++j) {
            int ret=1;
            for(int i = 1; i<=j; ++i) {
                ret*=i;
            }
            sum+=ret;
        }
        System.out.println(sum);
    }
}
